Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add operator impl #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

add operator impl #7

wants to merge 2 commits into from

Conversation

ritch
Copy link

@ritch ritch commented Apr 17, 2023

No description provided.

@@ -0,0 +1,6 @@
fiftyone:
version: ~0.21.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This defines the compatible version using semver matchers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need a way to also define the teams compatible version.

Copy link
Contributor

@brimoor brimoor Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every version of the Teams SDK has a corresponding OSS version (a range of compatible OSS versions, in fact), so we could require all users to "speak" OSS versions for now

@@ -0,0 +1,6 @@
fiftyone:
version: ~0.21.0
name: '@voxel51/fiftyone-docs-search'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should encourage this pattern, which is to match the github repo name to the plugin name. In theory we could also split this and then every "name" in this file is technically prefixed with the org name:

org: voxel51
name: fiftyone-docs-search
operators:
  - name: search-docs

Copy link

@kaixi-wang kaixi-wang Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should encourage this pattern, which is to match the github repo name to the plugin name. In theory we could also split this and then every "name" in this file is technically prefixed with the org name:

org: voxel51
name: fiftyone-docs-search
operators:
  - name: search-docs

I prefer this version. Typing @voxel51/fiftyone-docs-search for plugin name in zoo methods is an unnecessary pain

class SearchDocs(foo.DynamicOperator):
def __init__(self):
super().__init__(
"@voxel51/search-docs",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for anyone curious. This name match match the operator name defined in yaml. As far as the teams runtime is concerned, it will only refer to what is listed in the fiftyone.yml, not that it reads from this file.

def resolve_input(self, ctx):
inputs = types.Object()
inputs.str("query", label="Query", required=True)
return types.Property(inputs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolve_input returns a Property to allow for customizing the entire form view the property.view. This is because the entire form is actually defined by a Property of the operators definition (which is a types.Object).

In the operator type system, base types like object do not have ui metadata associated with them, since they should be re-usable and generic (in both senses of the word eg. List(String) - List is a "Generic" type aka template type.)

op = SearchDocs()
foo.register_operator(op)

def unregister():
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may be able to omit this and auto-unregister anything defined in the yaml.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should find a way to auto-unregister w/o needing this function

op = None

def register():
op = SearchDocs()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't update the top-level op object. You'd have to include global op in order to do that.
https://en.wikipedia.org/wiki/Variable_shadowing


op = None

def register():
Copy link
Contributor

@brimoor brimoor Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could auto-register as well. One way to do that would be to import this module and then automatically register all classes in the namespace that derive from foo.Operator. Or, if we wanted to be explicit, we could include the names of the operator(s?) in the yaml file that should be registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants